import React from "react";
import { useState, useCallback } from "react";
import A from "./A";
import B from "./B";
import C from "./C";
import D from "./D";


export default function DiffCom() {
  let [count, setCount] = useState(100);

  //缓存回调函数
  let fn = useCallback(() => {
    setCount(count => count + 1);
  }, []);// 哪些状态改变之后, 再重新的生成新函数

  return (
    <div style={{ padding: 50 }}>
      <h3>{count}</h3>
      <D onClick={fn}></D>
    </div>
  );
}
